package com.zr.java8.pattern.state.impl;

import com.zr.java8.pattern.state.OrderContext;
import com.zr.java8.pattern.state.OrderState;

// 已支付状态
public class PaidState implements OrderState {
    @Override
    public void pay(OrderContext context) {
        System.out.println("错误：订单已支付，无需重复支付！");
    }

    @Override
    public void ship(OrderContext context) {
        // 已支付状态下可以发货，发货后切换到已发货状态
        System.out.println("订单发货成功！");
        context.setState(new ShippedState()); // 状态切换
    }

    @Override
    public void complete(OrderContext context) {
        System.out.println("错误：订单未发货，无法完成！");
    }

    @Override
    public String getStateName() {
        return "已支付";
    }
}